package com.tuyou.springboot.mybatis.config;

import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisConfig {

//    @Primary
//    @Bean(name = "erpDataSource")
//    @ConfigurationProperties(prefix = "spring.datasource.erp")
//    public DataSource erpDataSource() {
//        return DruidDataSourceBuilder.create().build();
//    }

//    @Primary
//    @Bean(name = "erpSqlSessionFactory")
//    public SqlSessionFactory erpSqlSessionFactory(@Qualifier("erpDataSource") DataSource dataSource) throws Exception {
//        MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
//        bean.setDataSource(dataSource);
//        bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:com/keruyun/kic/ops/**/*.xml"));
//        // ConvenientEnum枚举自动转换为数据库值
//        bean.setTypeHandlers(new ConvenientEnumTypeHandler(ConvenientEnum.class));
//        bean.setVfs(SpringBootVFS.class);
//        return bean.getObject();
//    }

//    @Primary
//    @Bean(name = "erpTransactionManager")
//    public DataSourceTransactionManager erpTransactionManager(@Qualifier("erpDataSource") DataSource dataSource) {
//        return new DataSourceTransactionManager(dataSource);
//    }
//
//    @Primary
//    @Bean(name = "erpSqlSessionTemplate")
//    public SqlSessionTemplate kicOpsSqlSessionTemplate(@Qualifier("erpSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
//        return new SqlSessionTemplate(sqlSessionFactory);
//    }
}